ROICashFlowEntry

class ROICashFlowEntry(val dateInt: Int, val longValue: Long, val investCurr: CurrencyType, startDateInt: Int, val txnType: String? = null, val source: MoneydanceSyncableItem? = null) : Comparable<ROICashFlowEntry>

Represents a single cash flow entry used in Internal Rate of Return (IRR), or Return on Investment (ROI) calculations.

Each entry records the cash flow amount, its date, and the number of years between the cash flow and the start of the reporting period. The cash flow should represent a deposit or withdrawal

reinvested investment income (back into shares) - e.g. DIVIDEND_REINVEST - should typically be excluded as this will be reflected in the share balance of the security account anyway.

Sign Convention

Moneydance uses a standard financial convention:

  • Positive values = cash outflows (e.g. investments - e.g. buy, exp),

  • Negative values = cash inflows (e.g. proceeds - i.e. sell, div, inc), This aligns with discounted cash flow conventions and does not affect result validity (i.e. you could reverse all the signs and get the same result)

Note: As this object is mutable (i.e. by calling setStartDate) you should use clone if you require multiple copies of this cash flow.

Cashflow entries can be either a transaction or a total amount (account balance).

Parameters

dateInt

The entry's date.

longValue

The entry's value as a long, already expressed in terms of the destination currency investCurr.

investCurr

Currency to use (e.g. dollars, euro, etc., not shares).

startDateInt

The start of the reporting period. This can be changed later by calling setStartDate and it will recalculate annumsInPeriod on all entries.

txnType

The transaction type that generated this cash flow entry (optional, can be null)

source

Optional - the source object that originated this cash flow entry. This will often be SplitTxn, but could for example be an Account where an opening/closing balance is used

Constructors

Link copied to clipboard
constructor(dateInt: Int, longValue: Long, investCurr: CurrencyType, startDateInt: Int, txnType: String? = null, source: MoneydanceSyncableItem? = null)
constructor(dateInt: Int, longValue: Long, investCurr: CurrencyType, startDateInt: Int)

Cashflow entries constructor. Simple version with no transaction type or source. Refer main constructor for details of parameters. (compatibility with the pre-MD2027 constructor for any java / api usage)

constructor(splitTxn: SplitTxn, txnType: InvestTxnType?, investCurr: CurrencyType, startDateInt: Int)

Constructor from a security transaction (automatically determines the txnType and source settings).

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

The amount expressed in terms of the destination currency (dollars, euro, etc.). This is kept as a double and not as a long to avoid needless conversions during computation.

Functions

Link copied to clipboard

The number of days from the cash flows start date to this entry's date (inclusive), divided by 365

Link copied to clipboard

Returns a clone of this cashflow (containing copies of the data fields).

fun clone(toCurr: CurrencyType, toDate: Int? = null): ROICashFlowEntry

Returns a clone of this cashflow whilst also converting the currency and value(s) (all other fields are copied). Note: This currency conversion can either use the existing cash flow entry's dateInt (default) - i.e. include FX impact in IRR, or the optional toDate parameter when excluding FX impacts - i.e. constant currency / exclude FX impact in IRR.

Link copied to clipboard
open operator override fun compareTo(other: ROICashFlowEntry): Int
Link copied to clipboard
fun setStartDate(startDateInt: Int)

Define the start date for the cash flow(s) and compute/recompute the number of years from the start date to this entry's date (inclusive). Even though they are invalid, this method tolerates starting dates that are after the cash flow entry date to ensure that the number of years is always positive, since it is passed into Math.pow().

Link copied to clipboard
open override fun toString(): String